package com.yipei.business.controller;

import com.yipei.business.domain.MlDailySettlementInfo;
import com.yipei.business.service.IMlDailySettlementInfoService;
import com.yipei.common.annotation.Log;
import com.yipei.common.core.controller.BaseController;
import com.yipei.common.core.domain.AjaxResult;
import com.yipei.common.core.page.TableDataInfo;
import com.yipei.common.enums.BusinessType;
import com.yipei.common.utils.poi.ExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 日结算信息Controller
 *
 * @author yipei
 * @date 2024-12-21
 */
@RestController
@RequestMapping("/business/dailysettlement")
@Api(tags = "日结算信息", description = "日结算信息管理")
public class MlDailySettlementInfoController extends BaseController {
    @Autowired
    private IMlDailySettlementInfoService mlDailySettlementInfoService;

    /**
     * 查询日结算信息列表
     */
    //@PreAuthorize("@ss.hasPermi('business:dailysettlement:list')")
    @ApiOperation("日结算信息获取数据")
    @GetMapping("/list")
    public TableDataInfo list(MlDailySettlementInfo mlDailySettlementInfo) {
        startPage();
        List<MlDailySettlementInfo> list = mlDailySettlementInfoService.selectMlDailySettlementInfoList(mlDailySettlementInfo);
        return getDataTable(list);
    }

    /**
     * 导出日结算信息列表
     */
    //@PreAuthorize("@ss.hasPermi('business:dailysettlement:export')")
    @ApiOperation("日结算信息导出数据")
    @Log(title = "日结算信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MlDailySettlementInfo mlDailySettlementInfo) {
        List<MlDailySettlementInfo> list = mlDailySettlementInfoService.selectMlDailySettlementInfoList(mlDailySettlementInfo);
        ExcelUtil<MlDailySettlementInfo> util = new ExcelUtil<MlDailySettlementInfo>(MlDailySettlementInfo.class);
        util.exportExcel(response, list, "日结算信息数据");
    }

    /**
     * 获取日结算信息详细信息
     */
    //@PreAuthorize("@ss.hasPermi('business:dailysettlement:query')")
    @ApiOperation("日结算信息通过ID获取数据")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(mlDailySettlementInfoService.selectMlDailySettlementInfoById(id));
    }

    /**
     * 新增日结算信息
     */
    //@PreAuthorize("@ss.hasPermi('business:dailysettlement:add')")
    @ApiOperation("日结算信息新增数据")
    @Log(title = "日结算信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MlDailySettlementInfo mlDailySettlementInfo) {
        return toAjax(mlDailySettlementInfoService.insertMlDailySettlementInfo(mlDailySettlementInfo));
    }

    /**
     * 修改日结算信息
     */
    //@PreAuthorize("@ss.hasPermi('business:dailysettlement:edit')")
    @ApiOperation("日结算信息修改数据")
    @Log(title = "日结算信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MlDailySettlementInfo mlDailySettlementInfo) {
        return toAjax(mlDailySettlementInfoService.updateMlDailySettlementInfo(mlDailySettlementInfo));
    }

    /**
     * 删除日结算信息
     */
    //@PreAuthorize("@ss.hasPermi('business:dailysettlement:remove')")
    @ApiOperation("日结算信息删除数据")
    @Log(title = "日结算信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(mlDailySettlementInfoService.deleteMlDailySettlementInfoByIds(ids));
    }
}
